<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>书籍类别选择</title>
<script type="text/javascript">
	function getParent(){
		var id=document.getElementById("book_type_id").value;
		window.opener.document.getElementById("bookTypeId").value=id;
		
		var name=document.getElementById("book_type_name").value;
		window.opener.document.getElementById("bookTypeName").value=name;
		
		window.close();
	}
	function setValue(key,value){
		document.getElementById("book_type_id").value=key;
		document.getElementById("book_type_name").value=value;
	}
	function waiting(){
		document.getElementById("waiting").style.display='block';
	}
</script>
</head>
<body>
	<div id="waiting" style="display: none;text-align: center;"><img alt="等待" src="/image/front/loading.gif"></div>
	<form action="">
		<input type="hidden" id="book_type_id" name="bookTypeId">
		<input type="hidden" id="book_type_name" name="bookTypeName">
		<table width="100%" border="0">
			<tr>
				<td colspan="5">导航:
					<s:a action="type_bookTypeForId" namespace="/control/book">
							<s:param name="typeId" value=""></s:param>
							<b onclick="waiting()">顶级目录</b>
					</s:a>
					<s:iterator var="item" value="mapNavigation">
						>><s:a action="type_bookTypeForId" namespace="/control/book">
							<s:param name="typeId" value="#item.key"></s:param>
							<b onclick="waiting()">${item.value}</b>
						</s:a>
					</s:iterator>
				</td>
			</tr>
			<tr>
				<s:iterator value="types" var="_type" status="loop">
				<td>
					<c:if test="${fn:length(_type.types)>0}">
						<s:a action="type_bookTypeForId" namespace="/control/book">
							<s:param name="typeId" value="#_type.id"></s:param>
							<b onclick="waiting()">${_type.name}</b>
						</s:a>
					</c:if>
					<c:if test="${fn:length(_type.types)==0}">
						<input type="radio" name="bookType" onclick="javaScript:setValue('${_type.id}','${_type.name}')">${_type.name}
					</c:if>
					</td>
					<c:if test="${loop.count%5==0}"></tr><tr></c:if>
				</s:iterator>
			</tr>
			<tr>
				<td colspan="5" align="center">
					<input type="button" onclick="javaScript:getParent()" value="确定">
					<input type="reset" value="取消">
				</td>
			</tr>
		</table>
	</form>
</body>
</html>